<?php
namespace Common\Controller;
use \base\BridgeTrait;

class Private extends Controller {
	
	use \base\BridgeTrait;
	
	//当前用户
	var $user=array();
	var $user_id;
	//网站相关配置
	var $config=array();
	// 分页展示数
	protected $limit = 20;
	//缓存时间 s
	protected $cacheTime = 120;
	
	

	protected  function _initialize() {
		parent::_initialize();
		if (!$_SESSION["user"]) {
			$_SESSION["back_url"] = __SELF__;
			if( IS_AJAX ) {
				$this->return_data(-999, '没有访问权限！');
			} else {
				$this->redirect('/User/login');
			}
			return false;
		}
		if(is_file('./site.inc.php')) {
			$this->config = @include('./site.inc.php');
		} else {
			$common = '//站点配置文件';
			$this->config = M('SystemConfig')->getField('code,value');
			$content  = "<?php \n".$common."\nreturn ".var_export($this->config,true).";\n?>";
			file_put_contents('./site.inc.php',$content);
		}
		$this->user		=	unserialize(stripcslashes($_SESSION["user"]));
		$this->user_id	=	intval($this->user['user_id']);
		$this->assign("user", $this->user);
		$this->assign("config",$this->config);
    }


}

